home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / proxy14.arj / FRINGE.PRX < prev    next >
Text File  |  1994-03-04  |  969b  |  29 lines

  1. // test if two binary trees have the same leaves
  2. // the trees can be represented by sequences of sequences
  3. // task pi (i=1,2) outputs the next leaf of tree i
  4. // task p3 inputs two values and tests for equality
  5.  
  6. next(x,out) {if(x==[]) return;
  7.          if(is_number x) {out!x;return;}
  8.          next(hd x,out);
  9.          next(tl x,out);};
  10. eos="eos";
  11. ch1=channel();
  12. ch2=channel();
  13. tree1=[1,[2,[3],4]];
  14. tree2=[[1,2],3,[4]];
  15. task p1(out) {print "starting p1";next(tree1,out);
  16.               out!eos;};
  17. task p2(out) {print "starting p2";next(tree2,out);
  18.               out!eos;};
  19. task p3(in1,in2;x,y) {print "starting p3";in1?x;in2?y;
  20.                        while((x!=eos) || (y!=eos))
  21.                         {if(x!=y) {writeln("not equal");skip;}
  22.                          in1?x;in2?y;
  23.                          }
  24.                        writeln("equal");};
  25. task main() {start p1(ch1);
  26.              start p2(ch2);
  27.              start p3(ch1,ch2);};
  28. end
  29.